package com.learn.quartz.listener;

import com.learn.quartz.service.ScheduleJobService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 监听容器启动,并开始从数据库加在定时任务
 * https://juejin.cn/post/6921270284360089614?from=search-suggest
 * @author:         MI
 * @email:          448341911@qq.com
 * @createDate:     2023/10/28 22:56
 * @updateUser:     MI
 * @updateDate:     2023/10/28 22:56
 * @updateRemark:   修改内容
 * @version:        v1.0
 */
@Component
public class ScheduleJobInitListener implements CommandLineRunner {

    @Resource
    private ScheduleJobService scheduleJobService;

    @Override
    public void run(String... args) throws Exception {
        scheduleJobService.startJob();
    }
}
